package com.xyzboom.compiler.excepitons.fa

open class IllegalRegexException : Exception {
    protected constructor(s: String) : super(s)
    constructor() : super()

    companion object {
        fun unexpectedChar(c: Char, index: Int, regex: String): IllegalRegexException {
            val messageSb = StringBuilder("IllegalRegex: unexpected '$c' at $index\n")
            messageSb.append("\t$regex\n\t")
            for (i in 0 until index) {
                messageSb.append(' ')
            }
            messageSb.append('^')
            return UnexpectedCharException(c, index, regex, messageSb.toString())
        }

        fun lackOfChar(c: Char) = LackOfCharException(c, "IllegalRegex: lack of '$c' in expression!")
    }
}